﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WSServer
{
    public enum WSSocketReceiveMessageType
    {
        kSocketRecvMessageTypeNormal = 0,
        kSocketRecvMessageTypeRegisterService = 1,
        kSocketRecvMessageTypeRefreshToken = 2,
        kSocketRecvMessageTypeMessage = 3,
        kSocketRecvMessageTypeRecvRecip = 4,
        kSocketRecvMessageTypeRegisteredSuccess = 5
    }
    public class WSRequest
    {
        public WSSocketReceiveMessageType message_type { get; set; }
        public string identifier { get; set; }
        public string token { get; set; }
        public string state { get; set; }
        public bool isValidRequestWithSocket(WSSocket socket)
        {   
            if(message_type == WSSocketReceiveMessageType.kSocketRecvMessageTypeRefreshToken)
                return identifier == socket.identifier;
            if (message_type == WSSocketReceiveMessageType.kSocketRecvMessageTypeRegisterService)
                return true;
            return socket.identifier == identifier && socket.token.access_token == token && socket.token.expired_in > 0;
        }

    }
}
